﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;

public partial class ContactUS : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) return;
        if (Request.QueryString["mess"] == "1")
            Literal1.Text = "<script type=\"text/javascript\">" +
                            "$(function() { " +
                            "alert(\"Cảm ơn bạn đã liên hệ!\");" +
                            "});" +
                            "</script>";
        else
            if (Request.QueryString["mess"] == "0")
            {
                Literal1.Text = "<script type=\"text/javascript\">" +
                                "$(function() { " +
                                "alert(\"Email của bạn chưa được gửi đi!\");" +
                                "});" +
                                "</script>";
            }
    }
    protected void butt_send_Click(object sender, EventArgs e)
    {
        try
        {
           // string email_contact = "vietcare@vietcare.us";//funtion.GetValueWebConfig("email_contact");
          //  string pass_email_contact = "";//funtion.GetValueWebConfig("pass_email_contact");
           //string smtp = "smtp.gmail.com";//funtion.GetValueWebConfig("smtp");

            //string from = txt_email.Text;
            //string to = email_contact;//mình test bằng Gmail day la mail được gui toi
            //MailMessage message = new MailMessage(from, to);
            //message.IsBodyHtml = true;
            //message.Subject = txt_tieude.Text;
            //message.Body = "Họ tên: " + txt_hoten.Text + "<br/>" +
            //                "\nEmail: " + txt_email.Text + "<br/>" +
            //                "\nĐịa chỉ: " + txt_diachi.Text + "<br/>" +
            //                "\nĐiện thoại: " + txt_dienthoai.Text + "<br/>" +
            //                "\n-----------------------------------------------------" + "<br/>" +
            //                "\nNội dung: " + txt_noidung.Text;
            //SmtpClient client = new SmtpClient(smtp);

            ////port:587_smtp.gmail.com
            ////587: port smtp gmail sử dụng, nếu dùng mail khác bạn cần biết port smtp của nó
            ////-----------------------------------------------------------------------------------
            //client.UseDefaultCredentials = false;
            ////client.EnableSsl = true;//dùng cho server có sử dụng lớp bảo vệ qazmlp!@#$%^
            //System.Net.NetworkCredential auth = new System.Net.NetworkCredential(email_contact, pass_email_contact);
            //client.Credentials = auth;
            //client.Port = 995;
            //client.Send(message);
            
           // Gmail.Send(txt_email.Text, email_contact,txt_tieude.Text, txt_noidung.Text);
            Response.Redirect("ContactUs.aspx?mess=1");
        }
        catch { }
        Response.Redirect("ContactUs.aspx?mess=0");
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        txt_diachi.Text = "";
        txt_dienthoai.Text = "";
        txt_email.Text = "";
        txt_hoten.Text = "";
        txt_noidung.Text = "";
        txt_tieude.Text = "";
    }
}
